Skip to content

feat(snowflake): support invoking dynamically-resolved functions via IDENTIFIER()#7796

Merged
georgesittas merged 2 commits into
tobymao:mainfrom
eruditmorina:support-dynamic-identifiers
Jun 25, 2026
Merged

feat(snowflake): support invoking dynamically-resolved functions via IDENTIFIER()#7796
georgesittas merged 2 commits into
tobymao:mainfrom
eruditmorina:support-dynamic-identifiers

Conversation

@eruditmorina

Copy link
Copy Markdown
Contributor

Summary

Snowflake allows a function to be invoked under a dynamically-resolved name, e.g. IDENTIFIER('my_func')(1, 2) or IDENTIFIER($fn)(). Previously the parser handled IDENTIFIER(...) itself but raised a ParseError on the trailing argument list:

ParseError: Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Aliases'>

failing some of Snowflake's documented examples:

SET fn = 'add_one';
SELECT IDENTIFIER($fn)(41);
SELECT IDENTIFIER('my_func')(1, 2);
SELECT IDENTIFIER($fn)();

The aim of this PR is to add support for Snowflake's dynamic function invocation through IDENTIFIER(). DynamicIdentifier now carries an optional expressions arg holding the call arguments. The Snowflake parser consumes a trailing argument list after IDENTIFIER(...), and generation emits the call form, preserving the distinction between a name reference (IDENTIFIER('f')) and a zero-arg invocation (IDENTIFIER('f')()). Transpiling to other dialects resolves the call to a plain function call, e.g. DuckDB my_func(1, 2). Also added tests for covering the use-cases.

@georgesittas georgesittas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Comment thread sqlglot/generators/snowflake.py
Comment thread sqlglot/generator.py Outdated

@georgesittas georgesittas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍

@georgesittas georgesittas merged commit 7a0a9ab into tobymao:main Jun 25, 2026
8 checks passed
@eruditmorina eruditmorina deleted the support-dynamic-identifiers branch June 25, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants